$(function () {

    $('.select-user').change(function () {
        var userid = $('.select-user').val();
        var result2 = Model.message.messageList({
            s_userid:userid
        })
        $('.clear').empty()
        model(result2);
    })
    var result = Model.message.findAllChat()
    var item = ''
    for (var i = 0; i < result.users.length; i++) {
        item += '  <option value="' + result.users[i].userid + '">' + result.users[i].nickname + '</option>';
    }
    $('.select-user').append(item)
    model(result);


})

function model(result) {
    var gridColumns_2_2_2 = [

        {
            id: 'content',
            title: '消息内容',
            type: 'string',
            columnClass: 'text-center',
            fastQuery: true,
            fastQueryType: 'eq'
        }
        ,
        {
            id: 'createTime',
            title: '创建时间',
            type: 'string',
            columnClass: 'text-center',
            fastQuery: true,
            fastQueryType: 'eq'
        }
    ];
    var gridOption_2_2_2 = {
        lang: 'zh-cn',
        ajaxLoad: false,
        loadAll: true,
        datas: result.data,
        columns: gridColumns_2_2_2,
        gridContainer: 'gridContainer_2_2_2',
        toolbarContainer: 'gridToolBarContainer_2_2_2',
        tools: '',
        pageSize: 5,
        pageSizeLimit: [1, 10, 20, 50]
    };
    var grid_2_2_2 = $.fn.dlshouwen.grid.init(gridOption_2_2_2);
    grid_2_2_2.load();
}
